//
//  BaseTableViewController.swift
//  weibo2
//
//  Created by xuwzh on 15/10/6.
//  Copyright © 2015年 xuwzh. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController ,VisitorLoginViewDelegate{

    var userLogin = false
    var visitorLoginView: VisitorLoginView?
    override func loadView() {
        
        if userLogin {
            //调用 loadview 的父类的方法，执行原有的代码
            super.loadView()
            return
        }
           ///替换视图
           ///xib 是从bundle里面加载的
       visitorLoginView = NSBundle.mainBundle().loadNibNamed("VisitorLogin", owner: nil, options: nil).last as? VisitorLoginView
        //设置代理
        
        visitorLoginView?.delegate=self
        
        view=visitorLoginView
        
        //设置导航栏左右按钮
        
        navigationItem.leftBarButtonItem=UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewLoginDidSelected")
        
        navigationItem.rightBarButtonItem=UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewRegisterDidSelected")
        
       
        
        
      
    
    }
    
    func visitorLoginViewLoginDidSelected() {
        
        let sb = UIStoryboard(name: "OAuth", bundle: nil)
                
        
        presentViewController(sb.instantiateInitialViewController()!, animated: true, completion: nil)
        
    }
    
    func visitorLoginViewRegisterDidSelected() {
        print("\(__FUNCTION__)")
    }
    
}
